import Home from '.././pages/home/index.vue';
import Menu from '.././pages/menu/index.vue';
import MenuTodo from '.././pages/menu/todo.vue';
import Login from '.././pages/logins/login.vue';
import Debounce from ".././pages/directive/debounce.vue"
import { createRouter, createWebHistory } from 'vue-router';
const routes = [
  // 路由重定向
  {
    path: '/',
    redirect: '/home/menu/todo',
  }, {
    path: '/debounce',
    component: Debounce
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    redirect:"/home/menu/todo",
    meta: {
      requiresAuth: true // 声明该页面需要验证用户身份才可访问
    },
    children: [
      {
        path: '/home/add',
        meta: {
          name: '添加',
          littleShow: true,
        },
        component: () =>
          import(
            /*webpackChunkName:"customTodo"*/ "../components/Add.vue"
          ),
      },
      {
        path: '/home/emitUser',
        meta: {
          name: '修改资料',
          littleShow: true,
        },
        component: () =>
          import(
            /*webpackChunkName:"customTodo"*/ "../components/EmitLogin.vue"
          ),
      },
      {
        path: '/home/addtwo',
        meta: {
          name: '添加',
          littleShow: true,
        },
        component: () =>
          import(
            /*webpackChunkName:"customTodo"*/ "../components/AddTwo.vue"
          ),
      },
      {
        path: '/home/menu',
        component: Menu,
        meta: {
          title: '菜单',
          icon: '&#x343a;',
          isShow: true,
          name: '菜单',

        },
        children: [
          {
            path: '/home/menu/todo',
            meta: {
              name: '系统首页',
              littleShow: true,
            },
            component: MenuTodo,
          },
          {
            path: '/home/custom/customTodoA',
            meta: {
              name: '客户列表',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"customTodo"*/ '.././pages/custom/customTodo.vue'
              ),
          },
          {
            path: '/home/custom/kehushaixvanA',
            meta: {
              name: '客户筛选',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"kehushaixvan"*/ '.././pages/custom/kehushaixvan.vue'
              ),
          },
          {
            path: '/home/custom/xiaoshuoxiansuoA',
            meta: {
              name: '销售线索',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiaoshuoxiansuo"*/ '.././pages/custom/xiaoshuoxiansuo.vue'
              ),
          },
          {
            path: '/home/business/allbusinessA',
            meta: {
              name: '全部商机',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"allbusiness"*/ '.././pages/business/allbusiness.vue'
              ),
          },
          {
            path: '/home/goods/allGoodsA',
            meta: {
              name: '全部订单',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"allGoods"*/ '.././pages/goods/allGoods.vue'
              ),
          },
          {
            path: '/home/finance/backguanliA',
            meta: {
              name: '回款管理',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"backguanli"*/ '.././pages/finance/backguanli.vue'
              ),
          },
          {
            path: '/home/examine/backExamineA',
            meta: {
              name: '回款审批',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"backExamine"*/ '.././pages/examine/backExamine.vue'
              ),
          },
        ],
      },
      {
        path: '/home/custom',
        meta: {
          title: '客户',
          icon: '&#xe804;',
          isShow: true,
          name: '客户',
        },
        component: () =>
          import(/*webpackChunkName:"custom"*/ '.././pages/custom/index.vue'),
        children: [
          {
            path: '/home/custom/customTodo',
            meta: {
              name: '客户列表',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"customTodo"*/ '.././pages/custom/customTodo.vue'
              ),
          },
          {
            path: '/home/custom/gonghai',
            meta: {
              name: '公海客户',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"gonghai"*/ '.././pages/custom/gonghai.vue'
              ),
          },
          {
            path: '/home/custom/laji',
            meta: {
              name: '垃圾客户',
              littleShow: true,
            },
            component: () =>
              import(/*webpackChunkName:"laji"*/ '.././pages/custom/laji.vue'),
          },
          {
            path: '/home/custom/kehushaixvan',
            meta: {
              name: '客户筛选',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"kehushaixvan"*/ '.././pages/custom/kehushaixvan.vue'
              ),
          },
          {
            path: '/home/custom/xiaoshuoxiansuo',
            meta: {
              name: '销售线索',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiaoshuoxiansuo"*/ '.././pages/custom/xiaoshuoxiansuo.vue'
              ),
          },
          {
            path: '/home/custom/gonggongxiansuo',
            meta: {
              name: '公共线索',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"gonggongxiansuo"*/ '.././pages/custom/gonggongxiansuo.vue'
              ),
          },
          {
            path: '/home/custom/lianxiren',
            meta: {
              name: '联系人列表',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"lianxiren"*/ '.././pages/custom/lianxiren.vue'
              ),
          },
          {
            path: '/home/custom/genjin',
            meta: {
              name: '跟进记录',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"genjin"*/ '.././pages/custom/genjin.vue'
              ),
          },
          {
            path: '/home/custom/components/add',
            meta: {
              name: '添加',
              littleShow: false,
            },
            component: () =>
              import(
                /*webpackChunkName:"genjin"*/ '.././pages/custom/components/add.vue'
              ),
          },
          {
            path: '/home/custom/components/update',
            meta: {
              name: '修改',
              littleShow: false,
            },
            component: () =>
              import(
                /*webpackChunkName:"genjin"*/ '.././pages/custom/components/update.vue'
              ),
          },
        ],
      },
      {
        path: '/home/business',
        meta: {
          title: '商机',
          icon: '&#xe667;',
          isShow: true,
          name: '商机',
        },
        component: () =>
          import(
            /*webpackChunkName:"business"*/ '.././pages/business/index.vue'
          ),
        children: [
          {
            path: '/home/business/allbusiness',
            meta: {
              name: '全部商机',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"allbusiness"*/ '.././pages/business/allbusiness.vue'
              ),
          },
          {
            path: '/home/business/myBusiness',
            meta: {
              name: '我的商机',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"myBusiness"*/ '.././pages/business/myBusiness.vue'
              ),
          },
          {
            path: '/home/business/xiaBusiness',
            meta: {
              name: '下属商机',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiaBusiness"*/ '.././pages/business/xiaBusiness.vue'
              ),
          },
          {
            path: '/home/business/myxiezuo',
            meta: {
              name: '我协作的',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"myxiezuo"*/ '.././pages/business/myxiezuo.vue'
              ),
          },
          {
            path: '/home/business/okBusiness',
            meta: {
              name: '成交商机',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"okBusiness"*/ '.././pages/business/okBusiness.vue'
              ),
          },
          {
            path: '/home/business/addBusiness',
            meta: {
              name: '添加商机',
              littleShow: false,
            },
            component: () =>
              import(
                /*webpackChunkName:"addBusiness"*/ '.././pages/business/addBusiness.vue'
              ),
          },
          {
            path: '/home/business/xiashuxiezuo',
            meta: {
              name: '下属协作',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiashuxiezuo"*/ '.././pages/business/xiashuxiezuo.vue'
              ),
          },
        ],
      },
      {
        path: '/home/goods',
        meta: {
          title: '订单',
          icon: '&#xe62a;',
          isShow: true,
          name: '订单',
        },
        component: () =>
          import(/*webpackChunkName:"goods"*/ '.././pages/goods/index.vue'),
        children: [
          {
            path: '/home/goods/allGoods',
            meta: {
              name: '全部订单',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"allGoods"*/ '.././pages/goods/allGoods.vue'
              ),
          },
          {
            path: '/home/goods/xiaGoods',
            meta: {
              name: '下属订单',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiaGoods"*/ '.././pages/goods/xiaGoods.vue'
              ),
          },
          {
            path: '/home/goods/myXie',
            meta: {
              name: '我协作的',
              littleShow: true,
            },
            component: () =>
              import(/*webpackChunkName:"myXie"*/ '.././pages/goods/myXie.vue'),
          },
          {
            path: '/home/goods/xiaxie',
            meta: {
              name: '下属协作',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"xiaxie"*/ '.././pages/goods/xiaxie.vue'
              ),
          },
          {
            path: '/home/goods/addGoods',
            meta: {
              name: '添加订单',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"addGoods"*/ '.././pages/goods/addGoods.vue'
              ),
          },
          {
            path: '/home/goods/myGoods',
            meta: {
              name: '我的订单',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"myGoods"*/ '.././pages/goods/myGoods.vue'
              ),
          },
        ],
      },
      {
        path: '/home/finance',
        meta: {
          title: '财务',
          icon: '&#xe8ae;',
          isShow: true,
          name: '财务',
        },
        component: () =>
          import(/*webpackChunkName:"finance"*/ '.././pages/finance/index.vue'),
        children: [
          {
            path: '/home/finance/backFinance',
            meta: {
              name: '回款计划',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"backFinance"*/ '.././pages/finance/backFinance.vue'
              ),
          },
          {
            path: '/home/finance/backguanli',
            meta: {
              name: '回款管理',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"backguanli"*/ '.././pages/finance/backguanli.vue'
              ),
          },
          {
            path: '/home/finance/financeDeil',
            meta: {
              name: '回款详情',
              littleShow: false,
            },
            component: () =>
              import(
                /*webpackChunkName:"financeDeil"*/ '.././pages/finance/financeDeil.vue'
              ),
          },
          {
            path: '/home/finance/fapiao',
            meta: {
              name: '发票管理',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"fapiao"*/ '.././pages/finance/fapiao.vue'
              ),
          },
          {
            path: '/home/finance/feiyong',
            meta: {
              name: '费用管理',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"feiyong"*/ '.././pages/finance/feiyong.vue'
              ),
          },
          {
            path: '/home/finance/baoxiao',
            meta: {
              name: '报销管理',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"baoxiao"*/ '.././pages/finance/baoxiao.vue'
              ),
          },
        ],
      },
      {
        path: '/home/examine',
        meta: {
          title: '审批',
          icon: '&#xe60c;',
          isShow: true,
          name: '审批',
        },
        component: () =>
          import(/*webpackChunkName:"finance"*/ '.././pages/examine/index.vue'),
        children: [
          {
            path: '/home/examine/goodsExamine',
            meta: {
              name: '订单审批',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"goodsExamine"*/ '.././pages/examine/goodsExamine.vue'
              ),
          },
          {
            path: '/home/examine/backExamine',
            meta: {
              name: '回款审批',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"backExamine"*/ '.././pages/examine/backExamine.vue'
              ),
          },
          {
            path: '/home/examine/qingExamine',
            meta: {
              name: '请假审批',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingExamine"*/ '.././pages/examine/qingExamine.vue'
              ),
          },
        ],
      }, {
        path: '/home/ticket',
        meta: {
          title: '工单',
          icon: '&#xe609;',
          isShow: true,
          name: '工单',
        },
        component: () =>
          import(/*webpackChunkName:"please"*/ '.././pages/ticket/index.vue'),
        children: [
          {
            path: '/home/ticket/allticket',
            meta: {
              name: '全部工单',
              littleShow: true,
            },
            component: () =>
              import(
                '.././pages/ticket/allTicket.vue'
              ),
          },
          {
            path: '/home/ticket/myinstall',
            meta: {
              name: '我发起的',
              littleShow: true,
            },
            component: () =>
              import(
                '.././pages/ticket/myInstall.vue'
              ),
          }, {
            path: '/home/ticket/myage',
            meta: {
              name: '我处理的',
              littleShow: true,
            },
            component: () =>
              import(
                '.././pages/ticket/myAge.vue'
              ),
          }, {
            path: '/home/ticket/sendme',
            meta: {
              name: '抄送给我的',
              littleShow: true,
            },
            component: () =>
              import(
                '.././pages/ticket/sendMe.vue'
              ),
          }, {
            path: '/home/ticket/detail',
            meta: {
              // name: '抄送给我的',
              littleShow: true,
            },
            component: () =>
              import(
                '.././pages/ticket/detail.vue'
              ),
          }
        ]
      },
      {
        path: '/home/please',
        meta: {
          title: '申请',
          icon: '&#xe609;',
          isShow: true,
          name: '申请',
        },
        component: () =>
          import(/*webpackChunkName:"please"*/ '.././pages/please/index.vue'),
        children: [
          {
            path: '/home/please/qingjia',
            meta: {
              name: '请假申请',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '.././pages/please/qingjia.vue'
              ),
          },
          {
            path: '/home/please/chucai',
            meta: {
              name: '出差申请',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"chucai"*/ '.././pages/please/chucai.vue'
              ),
          },
          {
            path: '/home/please/jiekuan',
            meta: {
              name: '借款申请',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"jiekuan"*/ '.././pages/please/jiekuan.vue'
              ),
          },
          {
            path: '/home/please/gongzuo',
            meta: {
              name: '工作请示',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"gongzuo"*/ '.././pages/please/gongzuo.vue'
              ),
          },
          {
            path: '/home/please/kehu',
            meta: {
              name: '客户拜访',
              littleShow: true,
            },
            component: () =>
              import(/*webpackChunkName:"kehu"*/ '.././pages/please/kehu.vue'),
          },
        ],
      },
      // 统计报表
      {
        path: '/home/statistics',
        meta: {
          title: '统计报表',
          icon: '&#xe609;',
          isShow: true,
          name: '统计报表',
        },
        component: () =>
          import(/*webpackChunkName:"please"*/ '.././pages/statistics/statistics.vue'),
        children: [
          {
            path: '/home/statistics/xiaoshoufenxi',
            meta: {
              name: '销售预测分析',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/xiaoshoufenxi.vue'
              ),
          },
          {
            path: '/home/statistics/xiaoshouloudou',
            meta: {
              name: '销售漏斗分析',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/xiaoshouloudou.vue'
              ),
          },
          {
            path: '/home/statistics/yewuxinzeng',
            meta: {
              name: '业务新增汇总',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yewuxinzeng.vue'
              ),
          },
          {
            path: '/home/statistics/genjinjilu',
            meta: {
              name: '跟进记录汇总',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/genjinjilu.vue'
              ),
          },
          {
            path: '/home/statistics/yewuzonghe',
            meta: {
              name: '业务综合统计',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yewuzonghe.vue'
              ),
          },
          {
            path: '/home/statistics/yewuzengzhang',
            meta: {
              name: '业务增长统计',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yewuzengzhang.vue'
              ),
          },
          {
            path: '/home/statistics/yejimubiao',
            meta: {
              name: '业绩目标完成度',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yejimubiao.vue'
              ),
          },
          {
            path: '/home/statistics/chengjiaoshagnji',
            meta: {
              name: '成交商机汇总',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/chengjiaoshagnji.vue'
              ),
          },
          {
            path: '/home/statistics/huikuanjihua',
            meta: {
              name: '回款计划汇总',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/huikuanjihua.vue'
              ),
          },
          {
            path: '/home/statistics/chanpinxiaoliang',
            meta: {
              name: '产品销量汇总',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/chanpinxiaoliang.vue'
              ),
          },
          {
            path: '/home/statistics/caiwushuju',
            meta: {
              name: '财务数据分析',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/caiwushuju.vue'
              ),
          },
          {
            path: '/home/statistics/yejiwanchengdu',
            meta: {
              name: '业绩完成度排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yejiwanchengdu.vue'
              ),
          },
          {
            path: '/home/statistics/yewuxinzengpaiming',
            meta: {
              name: '业务新增排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/yewuxinzengpaiming.vue'
              ),
          },
          {
            path: '/home/statistics/chengjiaoshuju',
            meta: {
              name: '成交数据排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/chengjiaoshuju.vue'
              ),
          },
          {
            path: '/home/statistics/huikuanshujupaiming',
            meta: {
              name: '回款数据排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/huikuanshujupaiming.vue'
              ),
          },
          {
            path: '/home/statistics/zhuanhualv',
            meta: {
              name: '转化率排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/zhuanhualv.vue'
              ),
          },
          {
            path: '/home/statistics/lirunlv',
            meta: {
              name: '利润率排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/lirunlv.vue'
              ),
          },
          {
            path: '/home/statistics/genjinbaifang',
            meta: {
              name: '跟进拜访排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/genjinbaifang.vue'
              ),
          },
          {
            path: '/home/statistics/hujiaoshuju',
            meta: {
              name: '呼叫数据排名',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/hujiaoshuju.vue'
              ),
          },
          {
            path: '/home/statistics/kehushuxingfenxi',
            meta: {
              name: '客户属性分析',
              littleShow: true,
            },
            component: () =>
              import(
                /*webpackChunkName:"qingjia"*/ '../pages/statistics/kehushuxingfenxi.vue'
              ),
          },
          









        ],
      },




    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ],
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      guest: true // 声明该页面只能在未登录的情况下访问
    },
    component: Login,
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    meta: {
      requiresAuth: false // 404 页面不需要验证用户身份
    },
    component: () => import('@/pages/404/404.vue'),
  },
];
const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  const token = localStorage.getItem('token');
  // 判断该页面是否需要用户登录才可访问（即该页面是否需要验证用户身份）
  if (to.matched.some(record => record.meta.requiresAuth)) {
    if (!token) {
      // 如果用户未登录，则跳转到登录页面
      next({ name: 'login' });
      return;
    }
  }

  // 判断该页面是否只能在未登录的情况下访问（即该页面只能访客访问）
  if (to.matched.some(record => record.meta.guest)) {
    if (token) {
      // 如果用户已登录，则跳转到首页
      next({ name: 'home' });
      return;
    }
  }

  next();
})

export default router;
